/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package canvas;

import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.LayerManager;
import midlet.MainMidlet;
import util.SpriteClass;

/**
 *
 * @author aisyah
 */
public class SplashCanvas extends Canvas{
    private MainMidlet midlet;
    private Timer timer = new Timer();
    private  int index = 0;
  
    public SplashCanvas(MainMidlet midlet) {
         this.midlet = midlet;
         timer.schedule(new CountDown(), 1000);
    }



    protected void paint(Graphics g) {
        try {
            setFullScreenMode(true);
            // set background image
            SpriteClass bg = new SpriteClass(Image.createImage("/res/splash.png"));
            bg.setPosition(0, 0);
            LayerManager lmng = new LayerManager();
            lmng.append(bg);
             lmng.paint(g, 0, 0);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

     private class CountDown extends TimerTask {
        public void run() {
//            LanguageCanvas lCnvs = new LanguageCanvas(midlet, Display.getDisplay(midlet).getCurrent());
            LanguageCanvas lCnvs = new LanguageCanvas(midlet);
            Display.getDisplay(midlet).setCurrent(lCnvs);
            System.out.println("execute run");
        }
    }

    
}
